﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace DevelopersTestPad.Worksheets.DotNet
{
    internal partial class SubViewContainer : UserControl
    {
        /// <summary>
        /// Gets the OutputSubView.
        /// </summary>
        public OutputSubView Output { get { return outputSubView; } }

        /// <summary>
        /// Gets the CompilerErrorsSubView.
        /// </summary>
        public CompilerErrorsSubView CompilerErrors { get { return compilerErrorsSubView; } }

        /// <summary>
        /// Gets the RuntimeExceptionsSubView.
        /// </summary>
        public RuntimeExceptionsSubView RuntimeExceptions { get { return runtimeExceptionsSubView; } }

        /// <summary>
        /// Gets the PushOutputSubView.
        /// </summary>
        public PushOutputSubView PushOutput { get { return pushOutputSubView; } }

        /// <summary>
        /// Gets the ConsoleSubView.
        /// </summary>
        public ConsoleSubView Console { get { return consoleSubView; } }

        /// <summary>
        /// Gets the tab controls.
        /// </summary>
        private TabControl Tabs { get { return _customTabs; } }

        public SubViewContainer()
        {
            InitializeComponent();          
        }

        /// <summary>
        /// Activates the sub view.
        /// </summary>
        /// <param name="subView">The sub view to activate</param>
        public void Activate(SubView subView)
        {
            TabPage page = null;

            if (subView.Equals(Output))
            {
                page = tabPageOutput;
            }
            else if (subView.Equals(CompilerErrors))
            {
                page = tabPageCompilerErrors;
            }
            else if (subView.Equals(RuntimeExceptions))
            {
                page = tabPageRuntimeExceptions;
            }
            else if (subView.Equals(PushOutput))
            {
                page = tabPagePushOutput;
            }

            if (page != null)
            {
                ActivateTab(page);
            }
        }

        /// <summary>
        /// Activates a sub view tab page.
        /// </summary>
        /// <param name="page">The tab page.</param>
        private void ActivateTab(TabPage page)
        {
            if (Tabs.SelectedTab != null && Tabs.SelectedTab.Equals(page) == false)
            {
                Tabs.SelectedTab = page;
            }
        }

        private void HeaderPanel_ActionPermissionRequest(object sender, HeaderPanel.HeaderPanelActionPermissionRequest e)
        {
            e.IsMaximizeAvailable = true;
            e.IsMinimizeAvailable = true;
            e.IsRestoreAvailable = true;
        }

        private void HeaderPanel_Maximize(object sender, System.EventArgs e)
        {
        }

        private void HeaderPanel_Restore(object sender, System.EventArgs e)
        {
        }

        private void HeaderPanel_Minimize(object sender, EventArgs e)
        {
        }
    }
}
